package easy;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MorseCode {
	
	private static List<String> list = new ArrayList<String>(Arrays.asList(new String [] {
			  "-----",".----", "..---", "...--", "....-", 
			  ".....", "-....", "--...", "---..", "----.",  
			  ".-",  "-...",  "-.-.",  "-..",  ".",  "..-.",
			  "--.",  "....", "..",  ".---",  "-.-",  ".-..",
			  "--",  "-.",  "---",  ".--.",  "--.-",  ".-.",  "...",
			  "-",  "..-",  "...-",  ".--",  "-..-",  "-.--",  "--..", 
	}));
	private static List<String> eng = new ArrayList<String>(Arrays.asList(new String [] {
			"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
			"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
			"U", "V", "W", "X", "Y", "Z"
	}));
	
	public static void main(String[] args) {
		File file = new File(args[0]);
		BufferedReader in;
		try {
			in = new BufferedReader(new FileReader(file));
			String line;
			while ((line = in.readLine()) != null) {
				decode(line);
				System.out.println();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void decode(String str) {
		String [] s1 = str.split("  ");
		for (int i = 0; i < s1.length; i++) {
			String [] s2 = s1[i].split(" ");
			for(int j = 0; j < s2.length; j++) {
				System.out.print(eng.get(list.indexOf(s2[j])));
			}
			System.out.print(" ");
		}
	}
}
